package com.yst.webplugin.annotation;


import com.yst.executor.Page;

import java.io.Serializable;
import java.lang.annotation.*;
import java.util.List;
import java.util.Map;

@ResultType(resultTypes = {List.class, Page.PageOut.class})
@Target({ElementType.FIELD,ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Query {
    /**
     * class of query result
     */
    Class<?> modelClass() default Map.class;

    /**
     * parameter of valid
     */
    Class<? extends Serializable> validClass() default Default.class;
    /**
     * valid group
     */
    Class<?>[] validClassGroup() default {};
    /**
     * name of query, if value is empty,then use field name
     */
    String name();

    /**
     * sql script or name of sql, if value is empty,then use field name
     */
    String sqlOrSqlName() default "";

    /**
     * unselect fields
     */
    String[] disabledFields() default {};


    /**
     * batch query
     */
    @ResultType(resultTypes = {Map.class}, returnModelClass = true)
    @Target({ElementType.FIELD})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface BatchQuery{
        /**
         * name of query
         */
        String name() default "";

        /**
         * array of query
         */
        Query[] Queries() default {};

    }

    /**
     * batch query use config with model class
     */
    @ResultType(returnModelClass = true)
    @Target({ElementType.FIELD})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface BatchModelQuery{
        /**
         * config class
         */
        Class<?> modelQueryClass();
    }
}
